function getUserInfo() {
  $.ajax({
    url: '/my/user/userinfo',
    success: function (res) {
      console.log(res);
      if (res.status === 0) {
        //设置欢迎你 优先使用nickname 没有就用 username
        let name = res.data.nickname || res.data.username
        // console.log(name);
        $('.username').text(name)
        if (res.data.user_pic) {
          $('.lay-nav-img').attr('src', res.data.user_pic).show()
        } else {                //toUpperCase() 转换大写  ， substring(0,1)截取字符 第0个 截取到 第一个
          let first = res.data.username.substring(0, 1).toUpperCase()
          $('.text-avatar').text(first).css('display', 'inline-block')
        }
      }
    },

  })
}
getUserInfo()
//退出
$('.logout').on('click', function () {
  layer.confirm('你确定退出么', function (index) {
    localStorage.removeItem('token')
    location.href = './login.html'


    // layer.close(index);
  });
})